import React, { Component } from 'react'

export default class child extends Component {
  constructor () {
    super()
    console.log('--old-- constructor')
  }
  state = {
    name: '李华'
  }
  componentWillMount () {
    console.log('--old--componentWillMount')
  }
  render () {
    console.log('--old--render')
    return (
      <div>
        child
        <p>name is {this.state.name}</p>
        <p>count is {this.props.count} </p>
        <p>
          <button
            onClick={() => {
              this.setState({ name: '张文' })
            }}
          >
            更改
          </button>
        </p>
      </div>
    )
  }
  componentDidMount () {
    console.log('--componentDidMount--')
  }
  shouldComponentUpdate () {
    console.log('-- shouldComponentUpdate--')
    return true
  }
  componentDidUpdate () {
    console.log('-- componentDidUpdate--')
  }
  componentWillReceiveProps (props) {
    console.log('--componentWillReceiveProps--', props)
  }
  componentWillUnmount () {
    console.log('--componentWillUnmount--')
  }
}
